package com.ruoyi.data.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.data.domain.BondCbRedeemJsl;
import com.ruoyi.data.service.IBondCbRedeemJslService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 强赎Controller
 * 
 * @author leng.xz
 * @date 2024-05-02
 */
@Controller
@RequestMapping("/data/jslRedeem")
public class BondCbRedeemJslController extends BaseController
{
    private String prefix = "data/jslRedeem";

    @Autowired
    private IBondCbRedeemJslService bondCbRedeemJslService;

    @RequiresPermissions("data:jslRedeem:view")
    @GetMapping()
    public String jslRedeem()
    {
        return prefix + "/jslRedeem";
    }

    /**
     * 查询强赎列表
     */
    @RequiresPermissions("data:jslRedeem:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BondCbRedeemJsl bondCbRedeemJsl)
    {
        startPage();
        List<BondCbRedeemJsl> list = bondCbRedeemJslService.selectBondCbRedeemJslList(bondCbRedeemJsl);
        return getDataTable(list);
    }

    /**
     * 导出强赎列表
     */
    @RequiresPermissions("data:jslRedeem:export")
    @Log(title = "强赎", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BondCbRedeemJsl bondCbRedeemJsl)
    {
        List<BondCbRedeemJsl> list = bondCbRedeemJslService.selectBondCbRedeemJslList(bondCbRedeemJsl);
        ExcelUtil<BondCbRedeemJsl> util = new ExcelUtil<BondCbRedeemJsl>(BondCbRedeemJsl.class);
        return util.exportExcel(list, "jslRedeem");
    }

    /**
     * 新增强赎
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存强赎
     */
    @RequiresPermissions("data:jslRedeem:add")
    @Log(title = "强赎", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BondCbRedeemJsl bondCbRedeemJsl)
    {
        return toAjax(bondCbRedeemJslService.insertBondCbRedeemJsl(bondCbRedeemJsl));
    }

    /**
     * 修改强赎
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BondCbRedeemJsl bondCbRedeemJsl = bondCbRedeemJslService.selectBondCbRedeemJslById(id);
        mmap.put("bondCbRedeemJsl", bondCbRedeemJsl);
        return prefix + "/edit";
    }

    /**
     * 修改保存强赎
     */
    @RequiresPermissions("data:jslRedeem:edit")
    @Log(title = "强赎", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BondCbRedeemJsl bondCbRedeemJsl)
    {
        return toAjax(bondCbRedeemJslService.updateBondCbRedeemJsl(bondCbRedeemJsl));
    }

    /**
     * 删除强赎
     */
    @RequiresPermissions("data:jslRedeem:remove")
    @Log(title = "强赎", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bondCbRedeemJslService.deleteBondCbRedeemJslByIds(ids));
    }
}
